var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UIView = require("AA_UIView");
var PlayerDataManager = require("AA_PlayerDataManager");
var Excel = require("AA_Excel");
var UI_TuJianItem = require("AA_UI_TuJianItem");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_TuJian = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.itemNode = null;
    t.layout1 = null;
    t.layout2 = null;
    t.weijiesuo = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype._show = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
  };
  _creator.prototype.onEnable = function () {
    this.initUi();
  };
  _creator.prototype.initUi = function () {
    var e = Excel.Excel.shuiguo_all;
    var t = e.size;
    var o = [];
    var n = [];
    for (var i = 0; i < t; i++) {
      var a = e.get(i + 1 + 1e3);
      if (a.jinJieLv > 0) {
        if (this.isJieSuo(a)) {
          o.push(a);
        } else {
          n.push(a);
        }
      }
    }
    this.setShuiGuoItem(this.layout1, o);
    this.setShuiGuoItem(this.layout2, n);
  };
  _creator.prototype.setShuiGuoItem = function (e, t) {
    var o = e.children;
    o.forEach(function (e) {
      e.active = false;
    });
    for (var n = 0; n < t.length; n++) {
      var i = t[n];
      var a = o[n];
      if (!a) {
        a = cc.instantiate(this.itemNode);
        e.addChild(a);
      }
      a.x = 0;
      a.active = true;
      a.getComponent(UI_TuJianItem.default).initData(i);
    }
  };
  _creator.prototype.isJieSuo = function (e) {
    var t = this.shuiguoId(e.id);
    var o = this.shuiguoId(e.jinjieShuiGuoId);
    return !(!t || !o);
  };
  _creator.prototype.shuiguoId = function (e) {
    var t = PlayerDataManager.PlayerDataMgr.GetEquipDataById(e);
    var o = Excel.Excel.shuiguo(e);
    if (t) {
      if (t.isUnLock) {
        var n = o.jinJieLv;
        return t.level >= n;
      }
      return false;
    }
    return false;
  };
  _creator.prototype.onCloseView = function () {
    this._close();
  };
  __decorate([_property(cc.Node)], _creator.prototype, "itemNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "layout1", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "layout2", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "weijiesuo", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_TuJian;